#pragma once

#define GAME_MOVE_INTERVAL_MIN	100.0f
#define GAME_MOVE_INTERVAL_MAX	1000.0f

// Forward declarations.
namespace UI
{
	class Menu;
}
class SwipeObject;
class Grid;

class Game
{
	static Game* m_Singleton;
public:
	static Game* SetSingletonPtr( Game* a_Engine )	{ m_Singleton = a_Engine; return m_Singleton; }
	static Game* GetSingletonPtr()	{ return m_Singleton; }

	enum T_GAMESTATE
	{
		NORMAL = 0,
		LINEANIMATING,
		GAMEOVER,
		PAUSED
	};

	Game();
	~Game();

	void Update( float a_DT );

	T_GAMESTATE GetGameState();
	void SwitchGameState( T_GAMESTATE a_State );

	void IncrementScore( int a_Points );
	int GetScore();

	void Restart();

	Grid* GetGrid();
	
	float m_BlockMoveInterval;
private:
	void ConstructGameMenu();
	void ConstructPauseMenu();
	void ConstructGameOverMenu();

	T_GAMESTATE m_GameState;
	UI::Menu*	m_PauseMenu;
	UI::Menu*	m_GameMenu;
	UI::Menu*	m_GameOverMenu;

	SwipeObject* m_SwipeObject;

	Grid* m_Grid;

	CIwSVec2 m_SwipeMargin;

	CIw2DImage* m_PreviewBG;
	CIwSVec2 m_PreviewTopLeft;
	CIwSVec2 m_PreviewBGTopLeft;
	CIwSVec2 m_PreviewBGSize;

	int m_Score;
	bool m_CanRotate;
	bool m_IsPerformingSwipe;
};